function newIncoming() {
	greyLayer.open();
	win.window('open');
	form.form('clear');
	form.form('load',{
		labour_name:realName,
		labour_id:labour_id
	});
	form.url = '/pxglxt/incoming/save';
}
function editIncoming() {
	var row = grid.datagrid('getSelected');
	if (row) {
		greyLayer.open();
		win.window('open');
		form.form('load', '/pxglxt/incoming/getIncoming/' + row.id);
		form.url = '/pxglxt/incoming/update/' + row.id;
	} else {
		sys_alert('错误提示', '选择一个记录', 'error');
	}
}
function saveIncoming() {
	if (form.form('validate')) {
		form.form('submit', {
			url : form.url,
			success : function(data) {
				eval('data=' + data);
				if (data.success) {
					grid.datagrid('reload');
					win.window('close');
					greyLayer.close();
				} else {
					sys_alert('错误提示', data.msg, 'error');
				}
			}
		});
	}
}
//前台转销售
function toSales() {
	var row = grid.datagrid('getSelected');
	if (row) {
		form.url = '/pxglxt/incoming/toSales/' + row.id;
		form.form('submit', {
			url : form.url,
			success : function(data) {
				eval('data=' + data);
				if (data.success) {
					sys_alert('操作提示', '信息处理成功，已转到销售处理！', 'info');
					grid.datagrid('reload');
				} else {
					sys_alert('错误提示', data.msg, 'error');
				}
			}
		});
	} else {
		sys_alert('错误提示', '选择一个记录', 'error');
	}
	
}
function delIncoming() {
	// 删除前询问
	$.messager.confirm("用户确认", "确认要删除该记录？", function(r) {
		if (r) {
			var row = grid.datagrid('getSelected');
			if (row) {
				form.url = '/pxglxt/incoming/destroy/' + row.id;
				form.form('submit', {
					url : form.url,
					success : function(data) {
						eval('data=' + data);
						if (data.success) {
							grid.datagrid('reload');
						} else {
							sys_alert('错误提示', data.msg, 'error');
						}
					}
				});
			} else {
				sys_alert('错误提示', '选择一个记录', 'error');
			}

		}
	});

}
function closeWindow() {
	win.window('close');
	greyLayer.close();
}